package cn.thoughtworks.school.controllers;

import cn.thoughtworks.school.services.PasswordResetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Map;

@Controller
@RequestMapping(value = "/api/auth/passwordReset")
public class PasswordResetController {

    @Autowired
    private PasswordResetService passwordResetService;

    @RequestMapping(method = RequestMethod.POST)
    ResponseEntity createPasswordReset(@RequestBody Map<String, String> emailInfo) throws Exception {

        return passwordResetService.cretePasswordResetEmail(emailInfo);
    }
    @RequestMapping(method = RequestMethod.PUT)
    ResponseEntity resetPassword(@RequestBody Map<String, String> passwordInfo) throws Exception {

        return passwordResetService.resetPassword(passwordInfo);
    }

}
